package org.geektime.config;

import org.geektime.config.properties.CatProperties;
import org.geektime.entity.Cat;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@EnableConfigurationProperties(CatProperties.class)
@Configuration
public class CatConfiguration {

  @Autowired private CatProperties catProperties;

  @Bean
  public Cat tcat() {
    Cat cat = new Cat();
    cat.setPersonName(catProperties.getPersonName());
    cat.setName(catProperties.getName());
    cat.setColor(catProperties.getColor());
    return cat;
  }
}
